<template>
	<view>
		<u-collapse>
				<u-collapse-item  v-for="(item, index) in list" :title="item.time" :key="index" open="true">
					{{state[item.state]}}
					<view style="padding: 20rpx;" v-if="item.state!=2">
						<u-button type="warning" class="button" size="mini" @click="cancel(item.id)">取消</u-button>
					</view>
					
					<view style="padding: 20rpx;" v-else>
						<u-button type="primary" class="button" size="mini">已取消</u-button>
					</view>
					
				</u-collapse-item>
			</u-collapse>
	</view>
</template>

<script>
	import YuyueModel from '../../model/yuyue.js'
	export default {
		data() {
			return {
				list:[],
				state:['待处理','等待您的到来','已取消']
			}
		},
		onLoad() {
			this.get_data()
		},
		methods: {
			get_data()
			{
				let that=this
				YuyueModel.get().then(res=>{
					that.list=res.data
				})
			},
			cancel(id)
			{
				let that=this
				YuyueModel.cancel(id).then(res=>{
					if(res.code==200){
						uni.showToast({
							title:'已成功取消'
						})
						
						that.get_data()
					}
				})
			}
		}
	}
</script>

<style>
</style>
